/**
 * <copyright>
 * </copyright>
 *

 */
package com.ldh.mod4j.businessdomain.businessDomainDsl.impl;

import com.ldh.mod4j.businessdomain.businessDomainDsl.BusinessDomainDslPackage;
import com.ldh.mod4j.businessdomain.businessDomainDsl.DecimalProperty;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Decimal Property</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.DecimalPropertyImpl#getDataType <em>Data Type</em>}</li>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.DecimalPropertyImpl#getPrecision <em>Precision</em>}</li>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.DecimalPropertyImpl#getScale <em>Scale</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DecimalPropertyImpl extends PropertyImpl implements DecimalProperty
{
  /**
   * The default value of the '{@link #getDataType() <em>Data Type</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDataType()
   * @generated
   * @ordered
   */
  protected static final String DATA_TYPE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDataType() <em>Data Type</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDataType()
   * @generated
   * @ordered
   */
  protected String dataType = DATA_TYPE_EDEFAULT;

  /**
   * The default value of the '{@link #getPrecision() <em>Precision</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPrecision()
   * @generated
   * @ordered
   */
  protected static final int PRECISION_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getPrecision() <em>Precision</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPrecision()
   * @generated
   * @ordered
   */
  protected int precision = PRECISION_EDEFAULT;

  /**
   * The default value of the '{@link #getScale() <em>Scale</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getScale()
   * @generated
   * @ordered
   */
  protected static final int SCALE_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getScale() <em>Scale</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getScale()
   * @generated
   * @ordered
   */
  protected int scale = SCALE_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected DecimalPropertyImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return BusinessDomainDslPackage.Literals.DECIMAL_PROPERTY;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDataType()
  {
    return dataType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDataType(String newDataType)
  {
    String oldDataType = dataType;
    dataType = newDataType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.DECIMAL_PROPERTY__DATA_TYPE, oldDataType, dataType));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getPrecision()
  {
    return precision;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPrecision(int newPrecision)
  {
    int oldPrecision = precision;
    precision = newPrecision;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.DECIMAL_PROPERTY__PRECISION, oldPrecision, precision));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getScale()
  {
    return scale;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setScale(int newScale)
  {
    int oldScale = scale;
    scale = newScale;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.DECIMAL_PROPERTY__SCALE, oldScale, scale));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__DATA_TYPE:
        return getDataType();
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__PRECISION:
        return getPrecision();
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__SCALE:
        return getScale();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__DATA_TYPE:
        setDataType((String)newValue);
        return;
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__PRECISION:
        setPrecision((Integer)newValue);
        return;
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__SCALE:
        setScale((Integer)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__DATA_TYPE:
        setDataType(DATA_TYPE_EDEFAULT);
        return;
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__PRECISION:
        setPrecision(PRECISION_EDEFAULT);
        return;
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__SCALE:
        setScale(SCALE_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__DATA_TYPE:
        return DATA_TYPE_EDEFAULT == null ? dataType != null : !DATA_TYPE_EDEFAULT.equals(dataType);
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__PRECISION:
        return precision != PRECISION_EDEFAULT;
      case BusinessDomainDslPackage.DECIMAL_PROPERTY__SCALE:
        return scale != SCALE_EDEFAULT;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (dataType: ");
    result.append(dataType);
    result.append(", precision: ");
    result.append(precision);
    result.append(", scale: ");
    result.append(scale);
    result.append(')');
    return result.toString();
  }

} //DecimalPropertyImpl
